package com.jetlion.seekbar;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView textView = findViewById(R.id.textview);

        SeekBar seekBar = findViewById(R.id.seekbar);

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            //拖动产生进度条改变时调用该方法
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                Log.i("MainActivity", "执行了onProgressChanged方法");
                textView.setText("当前进度为：" + i);
            }

            //刚开始拖动时回调该方法
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                Log.i("MainActivity", "执行了onStartTrackingTouch方法");
            }

            //拖动停止时调用该方法
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                Log.i("MainActivity", "执行了onStopTrackingTouch方法");
            }
        });

    }
}